/*****************************************************************/ /**
 * \file   hal.h
 * \brief  arduino mcu port describe
 * 
 * \author monster
 * \date   April 2024
 *********************************************************************/
#ifndef __HAL_H
#define __HAL_H

#include <stdint.h>

#define sei()    __set_PRIMASK(0)
#define cli()    __set_PRIMAKS(1)

#ifdef __cplusplus
extern "C" {


#endif

#include "stm32/port_stm32.h"

///@brief I2C state
typedef enum {
	I2C_OK            = 0,
	I2C_DATA_TOO_LONG = 1,
	I2C_NACK_ADDR     = 2,
	I2C_NACK_DATA     = 3,
	I2C_ERROR         = 4,
	I2C_TIMEOUT       = 5,
	I2C_BUSY          = 6,
	I2C_UNKNOWN       = 9,
} i2c_status_t;

enum {
	I2C_8BIT_ADDR,
	I2C_16BIT_ADDR,
};

typedef uint8_t i2c_addr_size_t;

void delay(uint32_t ms);
uint32_t millis(void);
uint32_t micros(void);

#ifdef __cplusplus
} // extern "c"
#endif

#endif
